package com.xuetang9.fujian.staticproxy;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author: fujian
 * @description: 使用静态代理，代理安卓的登录，添加日志功能
 * @date: 2021/5/1 9:44
 * @version: V1.0
 * @package: com.xuetang9.fujian.staticproxy
 **/
public class LoginProxy implements ILogin{
    private ILogin login;                   // 真正做事情的对象

    public LoginProxy(ILogin login) {
        this.login = login;
    }

    @Override
    public boolean isLogin(String username, String password) {
        log("增加登录验证前的业务逻辑");
        boolean isLogin = this.login.isLogin(username, password);
        log("增加登录验证后的逻辑");
        return isLogin;
    }

    private void log(String message){
        Logger logger = Logger.getLogger(LoginProxy.class.getName());
        logger.log(Level.INFO,message);
    }
}
